<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"> 

<ui:composition template="/_transferencia.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">
			<h:form id="form">

				<h2>
					<h:outputText value="Enviar Documento" />
				</h2>
				
				<p:messages id="msg"/>
				<h:panelGrid columns="2">

				<p:fieldset><br />
				
				<h:outputLabel value="Funcionário Remetente: " for="func" />
				<h:outputText id="func" value="Leonardo Holanda" />
				
					<h:outputLink value="javascript:void(0)" onclick="dlgSetor.show();">
						<h:outputLabel value="Setor: " /><br />
					</h:outputLink>
					<p:inputText id="setor"
						value="#{enviarDocumentoBean.enviarDocumento.setor.nomeSetor}"
						onclick="dlgSetor.show();" readonly="true" rendered="true" onchange="handler">
					</p:inputText>&nbsp;
					
					<h:outputLink value="javascript:void(0)" onclick="dlgDestinatario.show();">
						<h:outputLabel value="Funcionario: " /><br />
					</h:outputLink>
					<p:inputText id="dest" value="#{enviarDocumentoBean.enviarDocumento.funcionario.nomeFunc}"
						onclick="dlgDestinatario.show();" readonly="true" rendered="true" onchange="handler">
					</p:inputText>
					
					<h:outputLabel value="Quem Recebeu: " for="funcReceb" />
					<h:outputText id="funcReceb" value="Macksuel Lopes" />	

					<h:outputLabel value="Data de Envio: " for="dateEnvio" />
						<p:calendar value="23/03/2012" id="dateEnvio">
							<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
						</p:calendar><br />
						
					<h:outputLabel value="Data do Recebimento: " for="dateReceb"/>
						<p:calendar value="27/03/2012" id="DateReceb">
							<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
						</p:calendar><br />	

					<p:commandButton value="Cadastrar" action="#{enviarDocumentoBean.grava}" ajax="false">
						<f:ajax execute="true" render="@form" />
					</p:commandButton> 
					
					<p:button id="cancela" type="reset" value="Limpar" />
					

				</p:fieldset>
				</h:panelGrid>			
				
			</h:form>

			<p:dialog header="Setores" widgetVar="dlgSetor" modal="true"
				width="800" showEffect="hide" hideEffect="fade" resizable="false" >
				<h:form id="form1">

					<p:outputPanel id="setores">
						<p:dataTable value="#{setorManagedBean.setores}" var="setor"
							paginator="true" rows="5" selectionMode="single">

							<p:column filterBy="#{setor.nomeSetor}" filterMatchMode="contains"
								headerText="Setor" sortBy="#{setor.nomeSetor}">
								<h:commandLink value="#{setor.nomeSetor}" onclick="dlgSetor.hide()"
									id="setor">
									<f:setPropertyActionListener target="#{enviarDocumentoBean.enviarDocumento.setor}" value="#{setor}" />
								</h:commandLink>
							</p:column>	
								
							<p:column headerText="Orgão" sortBy="#{setor.orgao.nomeOrgao}">
								<h:outputText value="#{setor.orgao.nomeOrgao}" />
							</p:column>

						</p:dataTable>
					</p:outputPanel>
				</h:form>
			</p:dialog>		
			
			<p:dialog header="Funcionarios" widgetVar="dlgDestinatario" modal="true"
				width="800" showEffect="hide" hideEffect="fade" resizable="false" >
				<h:form id="form2">

					<p:outputPanel id="funcionarios">
						<p:dataTable value="#{funcionarioManagedBean.funcionarios}" var="funcionario"
							paginator="true" rows="5" selectionMode="single">

							<p:column filterBy="#{funcionario.nomeFunc}" filterMatchMode="contains"
								headerText="Nome">
								<h:commandLink value="#{funcionario.nomeFunc}" onclick="dlgDestinatario.hide()"
									id="funcionario">
									<f:setPropertyActionListener target="#{enviarDocumentoBean.enviarDocumento.funcionario}" value="#{funcionario}" />
								</h:commandLink>
							</p:column>	
								
							<p:column headerText="Orgão" sortBy="#{setor.orgao.nomeOrgao}">
								<h:outputText value="#{setor.orgao.nomeOrgao}" />
							</p:column>

						</p:dataTable>
					</p:outputPanel>
				</h:form>
			</p:dialog>	

		</div>

	</ui:define>
</ui:composition>

</html>
